//
//  CYNQueueArray.m
//  QueueExample
//
//  Created by blank on 2017/11/28.
//  Copyright © 2017年 CYN. All rights reserved.
//

#import "CYNQueueArray.h"

@interface CYNQueueArray ()

@property(nonatomic, strong) NSMutableArray *queueArray;

@end

@implementation CYNQueueArray
- (id)dequeue {
    if (self.isEmpty) {
        return nil;
    }
    id obj = self.queueArray.firstObject;
    [self.queueArray removeObjectAtIndex:0];
    return obj;
}

- (void)enqueue:(id)obj {
    [self.queueArray addObject:obj];
}

- (void)clear {
    if (self.isEmpty) {
        return;
    }
    [self.queueArray removeAllObjects];
}

- (BOOL)isEmpty {
    return !self.queueArray.count;
}

- (NSMutableArray *)queueArray {
    if (!_queueArray.count) {
        _queueArray = [NSMutableArray array];
    }
    return _queueArray;
}




@end
